package com.qlogic.commons.utils.os;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class OsCommandResult implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -7694005812032291436L;
	
	public static final int ERROR = 0;
	public static final int INFO = 1;
	
	private int type = INFO;
	private List reultsRows = new ArrayList ();
	private boolean noOsResult;
	
	public OsCommandResult (int type) {
		this.type = type;
	}

	public OsCommandResult (String message) {
		this.type = ERROR;
		addRow (message);
	}

	public int getType() {
		return type;
	}
	
	public void addRow (String row) {
		reultsRows.add (row);
	}
	
	public String getRow (int rowIndex) {
		return (String)reultsRows.get (rowIndex);
	}
	
	public int getRowsCount () {
		return reultsRows.size ();
	}
	
	public InputStream format (String command, OsCommandResultFormater formater) {
		return formater.format (command, this);
	}
	
	public InputStream format (String command) {
		return new DefaultOsCommandResultFormater ().format (command, this);
	}

	public boolean isNoOsResult() {
		return noOsResult;
	}

	public void setNoOsResult(boolean noOsResult) {
		this.noOsResult = noOsResult;
	}
	
}
